{include file="public/header" /}



<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.adv_index_manage}</h3>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>

    <form id="link_form" enctype="multipart/form-data" method="post">
<!--        <div style="width: 300px;display: block;">-->
<!--            <img src="http://tbk.nimei.net.cn/uploads/20190813/4d4b0d9aac9727e426ef5573fb147a1f.png" width="300">-->
<!--        </div>-->
        <table class="ds-default-table">
            <thead>
            <tr class="thead">
                <th class="w300 align-center">模块名称</th>
                <th class="w300 align-center">宽 (像素)</th>
                <th class="w300 align-center">高 (像素)</th>
                <th class="w200 align-center">图片</th>
                <th class="w300 align-center">{$Think.lang.ds_handle}</th>
            </tr>
            </thead>
            <tbody>
            <tr class="hover" >
                <td class="name">模块1</td>
                <td class="name"><input type="text" name="width" id="adv_name" class="txt"></td>
                <td class="name"><input type="text" name="height" id="adv_name" class="txt"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr class="hover" >
                <td class="name">模块2</td>
                <td class="name"><input type="text" name="width"></td>
                <td class="name"><input type="text" name="height"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr class="hover" >
                <td class="name">模块3</td>
                <td class="name"><input type="text" name="width"></td>
                <td class="name"><input type="text" name="height"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr class="hover" >
                <td class="name">模块4</td>
                <td class="name"><input type="text" name="width"></td>
                <td class="name"><input type="text" name="height"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr class="hover" >
                <td class="name">模块5</td>
                <td class="name"><input type="text" name="width"></td>
                <td class="name"><input type="text" name="height"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr class="hover" >
                <td class="name">模块6</td>
                <td class="name"><input type="text" name="width"></td>
                <td class="name"><input type="text" name="height"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr class="hover" >
                <td class="name">模块7</td>
                <td class="name"><input type="text" name="width"></td>
                <td class="name"><input type="text" name="height"></td>
                <td class="w200 align-center">
                    <div class="dssc-goods-default-pic">
                        <div class="goodspic-uplaod">
                            <span></span>
                            <input type="hidden" name="videos" id="video_name"
                            />
                            <input type="file" hidefocus="true" name="video" id="videos" data-action="{:url('Adv/ajax_videos')}">
                            </span>
                            <p class="hint"></p>
                        </div>
                    </div>
                </td>
                <td class="align-center">
                    <select name="project_type">
                        {foreach name="type" item="v" key="ap_k" }
                        <option value='{$v.ap_id}'>
                            {if condition="($v.ap_name==1)"}视频广告
                            {elseif condition="($v.ap_name==2)"}商品促销
                            {elseif condition="($v.ap_name==3)"}项目定制
                            {elseif condition="($v.ap_name==4)"}文章类
                            {/if}
                        </option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="tfoot" style="text-align: center;">
                <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script type="text/javascript" src="{$Think.ADMIN_SITE_ROOT}/js/jquery.edit.js" charset="utf-8"></script>
<script src="{$Think.PLUGINS_SITE_ROOT}/layui/layui.js"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
<script>
    //按钮先执行验证再提交表单
    $(function() {
        $(document).on('change', '#videos', function () {
            $('#dataLoading').show();
            var files = document.getElementById('videos').files[0];
            var formData = new FormData();
            var obj = $(this);
            formData.append('file', files);
            var url = $(this).attr('data-action');
            $.ajax({
                //请求方式
                type: "POST",
                //请求地址
                url: url,
                data: formData,
                cache: false,  //默认是true，但是一般不做缓存
                processData: false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
                contentType: false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
                //请求成功
                success: function (result) {
                    if (result.msg == 1) {
                        $('.vide').empty();
                        $('#dataLoading').hide();
                        layer.msg('上传成功');
                        $("#video_name").val(result.files_name);
                        // $("type[name='old_filename']").val(result.old_name);
                    } else {
                        obj.val('');
                        $('#dataLoading').hide();
                        layer.msg('文件信息错误,请重新上传');
                        return false;
                    }
                },
                //请求失败，包含具体的错误信息
                error: function (e) {
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });

        });

    });


</script>
